package mi.payment.ui.base;

import android.os.Bundle;
import android.support.design.button.MaterialButton;
import android.view.View;
import android.widget.TextView;

import lainey.ui.widget.TitleView;
import mi.payment.R;
import mi.payment.constants.Configs;
import mi.payment.transaction.AutoFinishActivity;

/**
 * 输入金额页面
 */
public class InputMoneyActivity extends AutoFinishActivity {

    public String mInputAmount;

    public TextView mTvTitle;
    public MaterialButton mBtnOk;
    public AmountInputView amountInputView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_input_money);
        initView();
    }

    private void initView() {
        TitleView titleView = findViewById(R.id.title_view);
        mTvTitle = titleView.getCenterTextView();
        titleView.setLeftImageVisibility(View.GONE);

        amountInputView = findViewById(R.id.amountInputView);

        NumberKeyboard numberKeyboard = findViewById(R.id.numberKeyboard);
        numberKeyboard.setKeyClickCallback(
                new NumberKeyboard.KeyClickCallback() {

                    @Override
                    public void onNumClick(int keyNum) {
                        amountInputView.addText(keyNum + "");
                    }

                    @Override
                    public void onDelClick() {
                        if (Configs.isConfigKeyboardDot) {
                            amountInputView.setClickDot(true);
                            amountInputView.setRightIndex(0);
                        } else {
                            amountInputView.delLast();
                        }
                    }

                    @Override
                    public void onCleanClick() {
                        if (Configs.isConfigKeyboardDot) {
                            amountInputView.delLast();
                        } else {
                            amountInputView.clean();
                        }
                    }

                }
        );

        mBtnOk = findViewById(R.id.mb_ok);
        mBtnOk.setOnClickListener(this);
    }


}
